﻿using CardPlay.Model.ActionModel;
using CardPlay.Model.CardModel;
using CardPlay.Model.GameModel;
using CardPlay.Model.GameModel.Actions;

namespace CardPlay.DemoPack.Games.KlondikeVariants
{
    [Game("5921003A-6374-4EE6-8395-86D9E259428A", LevelOfDifficulty.Easy, LevelOfSkill.MostlyChance, DurationOfPlay.LessThan5Minutes, Family = FamilyName)]
    public class AgnesSorel : Klondike
    {
        public AgnesSorel()
        {
            NamesOfAdditionalPiles.Remove(Waste);

            MaximumDeals = 1;
            TableauBuildSequence = CardFaceSequence.SameColorDescendingRank;
            DealOutPattern = AnyTableau;
        }

        protected string DealOutPattern { get; set; }

        protected override void PrepareDealScript(DealScript script)
        {
            script.DealCardTo(Foundation1);
            base.PrepareDealScript(script);
        }

        protected override IAction QueryActionAt(PartLocation location)
        {
            var card = CardAt(location);
            if (card == null) return null;

            return location.Matches(Stock) && location.Index == this[Stock].TopIndex
                ? new DealOutTableauAction(this, location) { TargetPattern = DealOutPattern }
                : base.QueryActionAt(location);
        }

        protected override bool AllowedToBuildEmptyTableau(MovePileAction action)
        {
            return false;
        }
    }
}